//
//  MoveToForward.cpp
//  client
//
//  Created by DuanHongbo on 15/1/29.
//
//

#include "MoveToForward.h"


MoveToForward* MoveToForward::create(float duration, const Vec2& position,bool autoHeadOn , float initAngle)
{
    MoveToForward *ret = new (std::nothrow) MoveToForward();
    ret->initWithDuration(duration, Vec3(position.x,position.y,0),autoHeadOn,initAngle);
    ret->autorelease();
    
    return ret;
}

bool MoveToForward::initWithDuration(float duration, const Vec3& position,bool autoHeadOn , float initAngle)
{
    if (MoveByForward::initWithDuration(duration,position,autoHeadOn,initAngle))
    {
        _endPosition = position;
        return true;
    }
    
    return false;
}

MoveToForward* MoveToForward::clone() const
{
    // no copy constructor
    auto a = new (std::nothrow) MoveToForward();
    a->initWithDuration(_duration, _endPosition,m_autoHeadOn,m_initAngle);
    a->autorelease();
    return a;
}

void MoveToForward::startWithTarget(Node *target)
{
    MoveByForward::startWithTarget(target);
    _positionDelta = _endPosition - target->getPosition3D();
}

